
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<script type="text/javascript">
	$(document).ready(function() {
		<c:choose>
			<c:when test="${partner.id !=null and partner.id gt 0}">			
				$('#pageTitle').text('<spring:message code="editPartner.heading.view" />');
			</c:when>
			<c:otherwise>
				$('#pageTitle').text('<spring:message code="editPartner.heading" />');	
			</c:otherwise>
		</c:choose>	
		
		
		$("#countries").change(function() {
			loadDataViaAjax("loadStates.do", {
				"countryId" : this.value
			}, parseStatesJson);
		});
		
		$("#countries").change();
		
		$("#editPartnerForm").validate({
			rules : {
				name : {
					required : true
				}
			}
		});
	});
	
	function parseStatesJson(data) {
		var stateId = '${donor.state.id}';
		
		var html = '<option value="">Select</option>';
		if (data) {
			for (p in data) {
				if(stateId == p) {
					html += "<option selected='selected' value='" + p + "'>" + data[p] + "</option>";
				} else {
					html += "<option value='" + p + "'>" + data[p] + "</option>";
				}
			}
		}
		$("#states option").remove();
		$("#states").append(html);
	}
</script>
<br>
<div id="editPartnerDiv">
	<form:form name="editPartnerForm" id="editPartnerForm" action="savePartner.do" method="post" modelAttribute="partner">
		<form:hidden path="id" />
		<c:choose>
			<c:when test="${partner.fromProject=='true'}">
				<input type="hidden" name="fromProject" value="true" />
			</c:when>
			<c:otherwise>
				<input type="hidden" name="fromProject" value="false" />
			</c:otherwise>
		</c:choose>
		<table width="100%" border="0">
			<tr class="row">
				<td class="menu-heading" colspan="3"><spring:message code="editPartner.heading" /></td>
			</tr>
			<tr class="row">
				<td class="input-field" colspan="2"><%@ include file="/common/messages.jsp"%></td>
			</tr>
			<tr>
				<td style="vertical-align: top;"><table>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.id" /></td>
							<td class="input-field"><form:input path="id" cssClass="input-full-width" disabled="true" /></td>
							<td><form:errors path="id" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.name" /></td>
							<td class="input-field"><form:input path="partnerName" cssClass="input-full-width-req" /></td>
							<td><form:errors path="partnerName" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.Type" /></td>
							<td class="input-field"><form:select path="type">
									<form:option value="Cipe Partner" label="Cipe Partner" />
									<form:option value="Other" label="Other" />
								</form:select></td>
							<td><form:errors path="type" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.Status" /></td>
							<td class="input-field"><form:select path="status">
									<form:option value="Active" label="Active" />
									<form:option value="Inactive" label="Inactive" />
									<form:option value="Other" label="Other" />
								</form:select></td>
							<td><form:errors path="status" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.address1" /></td>
							<td class="input-field"><form:input path="address1" cssClass="input-full-width" /></td>
							<td><form:errors path="address1" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.address2" /></td>
							<td class="input-field"><form:input path="address2" cssClass="input-full-width" /></td>
							<td><form:errors path="address2" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.city" /></td>
							<td class="input-field"><form:input path="city" cssClass="input-full-width" /></td>
							<td><form:errors path="city" cssClass="error" /></td>
						</tr>
						<%-- <tr class="row">
							<td class="label"><spring:message code="editPartner.label.state" /></td>
							<td class="input-field"><form:input path="state.id" id="states" cssClass="input-full-width" /></td>
							<td><form:errors path="state" cssClass="error" /></td>
						</tr> --%>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.zipCode" /></td>
							<td class="input-field"><form:input path="zipCode" cssClass="input-full-width" /></td>
							<td><form:errors path="zipCode" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.country" /></td>
							<td class="input-field"><form:select path="country.id" id="countries">
									<form:options items="${countryList}" itemValue="id" itemLabel="displayName" />
								</form:select></td>
							<td><form:errors path="country.id" cssClass="error" /></td>
						</tr>
						<tr>
							<td class="label"><spring:message code="editPartner.label.state" /></td>
							<td class="input-field"><form:select path="state.id" id="states" cssClass="text_white">
								</form:select> <form:errors path="state.id" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.phone" /></td>
							<td class="input-field"><form:input path="phone" cssClass="input-full-width" /></td>
							<td><form:errors path="phone" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.fax" /></td>
							<td class="input-field"><form:input path="fax" cssClass="input-full-width" /></td>
							<td><form:errors path="fax" cssClass="error" /></td>
						</tr>
					</table></td>
				<td><table>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.email" /></td>
							<td class="input-field"><form:input path="email" cssClass="input-full-width" /></td>
							<td><form:errors path="email" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.url" /></td>
							<td class="input-field"><form:input path="url" cssClass="input-full-width" /></td>
							<td><form:errors path="url" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.ContactFirstName" /></td>
							<td class="input-field"><form:input path="contactFirstName" cssClass="input-full-width" /></td>
							<td><form:errors path="contactFirstName" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.ContactMiddleName" /></td>
							<td class="input-field"><form:input path="contactMiddleName" cssClass="input-full-width" /></td>
							<td><form:errors path="contactMiddleName" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.ContactLastName" /></td>
							<td class="input-field"><form:input path="contactLastName" cssClass="input-full-width" /></td>
							<td><form:errors path="contactLastName" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.ContactPhone" /></td>
							<td class="input-field"><form:input path="contactPhone" cssClass="input-full-width" /></td>
							<td><form:errors path="contactPhone" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.ContactFax" /></td>
							<td class="input-field"><form:input path="contactFax" cssClass="input-full-width" /></td>
							<td><form:errors path="contactFax" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.ContactEmail" /></td>
							<td class="input-field"><form:input path="contactEmail" cssClass="input-full-width" /></td>
							<td><form:errors path="contactEmail" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.lastUpdated" /></td>
							<td class="input-field"><form:input path="updationDate" cssClass="input-full-width" disabled="true" /></td>
							<td><form:errors path="updationDate" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.lastUpdatedBy" /></td>
							<td class="input-field"><form:input path="updatedBy" cssClass="input-full-width" disabled="true" /></td>
							<td><form:errors path="updatedBy" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.createDate" /></td>
							<td class="input-field"><form:input path="creationDate" cssClass="input-full-width" disabled="true" /></td>
							<td><form:errors path="creationDate" cssClass="error" /></td>
						</tr>
						<tr class="row">
							<td class="label"><spring:message code="editPartner.label.createdBy" /></td>
							<td class="input-field"><form:input path="createdBy" cssClass="input-full-width" disabled="true" /></td>
							<td><form:errors path="createdBy" cssClass="error" /></td>
						</tr>
					</table></td>
			</tr>
			<tr class="row">
				<td colspan="2" class="input-field"><sj:submit id="loginFormSubmit" target="editPartnerDiv" key="editPartner.button.save" validate="true" /></td>
			</tr>
		</table>
	</form:form>
</div>
